Extractor: Add extract_ruby_options across all language bindings#675
Conversation
…r module Co-authored-by: Felipe Felix <felipe.felix@maino.com.br> Co-authored-by: Everton <e.santos081992@gmail.com>
…icolons_to_Herb_module
marcoroth
left a comment
There was a problem hiding this comment.
Hey @Lusqinha, thanks for opening this pull request!
I'm happy to expose this functionality, but I'm really curious what the use case for this pull request is, do you have a specific need for this? 😅
Regarding the design, I'm wondering if we instead should expose this with some options on the existing extract_ruby method. Something like:
Herb.extract_ruby(source, semicolons: true)|
@marcoroth thanks for the feedback! We are planning to use this in Steep/RBS, more specifically in this PR: soutaro/steep#1836. It's because we need the Ruby code with semicolons to display the static typing errors correctly. I think this functionality could also be used in others projects like Sorbet and Packwerk. Sorry for the lack of information in the description of this PR, we are going to update this soon. About the design, I agree to use existing |
|
|
||
| require_relative "../test_helper" | ||
|
|
||
| module Extractor |
There was a problem hiding this comment.
I basically copied these C tests https://github.com/marcoroth/herb/blob/main/test/c/test_extract.c
|
Hello @marcoroth, Sorry for the long time to update this PR. We made the changes to use the optional argument, I think could be better the |
…icolons_to_Herb_module
|
Hello @marcoroth. We made the adjustments to the PR, could you review it again? |
|
Hey @Lusqinha and @felixefelip, Sorry for the delay here. I think given that we merged #902 this pull request might actually not be needed anymore. Unless I'm missing something: irb(main):003> source = "<% x = 1 %> <% y = 2 %>"
irb(main):004> result = Herb.extract_ruby(source)
=> " x = 1 ; y = 2 ;" |
|
Maybe we could still add the Herb.extract_ruby(source, semicolons: false)What do you think? |
…icolons_to_Herb_module
extract_ruby_options across all language bindings
|
Merged main and implemented the options-based API. Added three options:
Exposed across Ruby, JavaScript (WASM + Node native), Java, and Rust bindings with tests and docs. |
|
Thank you @Lusqinha, @felixefelip, and @esantos92! 🙏🏼 |
This pull request adds
semicolons,comments, andpreserve_positionsoptions toHerb.extract_rubyacross all language bindings (Ruby, JavaScript, Java, Rust).This was originally requested to use the extract Ruby code with semicolons in Steep/RBS, more specifically in this PR: soutaro/steep#1836. It's because we need the Ruby code with semicolons to display the static typing errors correctly. I think this functionality could also be used in others projects like Sorbet and Packwerk.
Resolves #100